package com.aps.algorithm.heuristic;


import com.aps.algorithm.heuristic.genetic.dto.ApsOperationDto;
import com.aps.common.model.genetic.Equipment;
import com.aps.common.model.genetic.Order;
import lombok.Getter;

import java.util.List;
import java.util.Map;


public class GeneticStrategyParams {
    /**
     * 基因序列
     */
    @Getter
    private List<ApsOperationDto> geneSequence;

    /**
     * 以订单ID为key，对应订单列表为value的Map
     */
    @Getter
    private Map<String, Order> orderMap;

    /**
     * 以设备类型为key，对应设备列表为value的Map
     */
    @Getter
    private Map<String, List<Equipment>> equipmentMap;

    /**
     * 是否存在机器时间冲突
     *
     */
    private boolean hasEquipmentConflicts;

    /**
     * @description: 设置是否存在机器冲突
     * @author: jsy
     * @time: 2025/10/14 11:16
     */
    public void setHasEquipmentConflicts(boolean hasEquipmentConflicts) {
        this.hasEquipmentConflicts = hasEquipmentConflicts;
    }

    /**
     * @description: 检查是否存在机器冲突
     * @author: jsy
     * @time: 2025/10/14 11:19
     */
    public boolean hasEquipmentConflicts() {
        return hasEquipmentConflicts;
    }

    private GeneticStrategyParams(Builder builder) {
        this.geneSequence = builder.geneSequence;
        this.orderMap = builder.orderMap;
        this.equipmentMap = builder.equipmentMap;
    }

    public static class Builder {
        /**
         * 基因序列
         */
        private List<ApsOperationDto> geneSequence;

        /**
         * 以订单ID为key，对应订单列表为value的Map
         */
        private Map<String, Order> orderMap;

        /**
         * 以设备类型为key，对应设备列表为value的Map
         */
        private Map<String, List<Equipment>> equipmentMap;

        public Builder addGeneSequence(List<ApsOperationDto> geneSequence) {
            this.geneSequence = geneSequence;
            return this;
        }

        public Builder addOrderMap(Map<String, Order> orderMap) {
            this.orderMap = orderMap;
            return this;
        }

        public Builder addEquipmentMap(Map<String, List<Equipment>> equipmentMap) {
            this.equipmentMap = equipmentMap;
            return this;
        }

        public GeneticStrategyParams build() {
            return new GeneticStrategyParams(this);
        }
    }
}
